package com.xhh.enjoyapp.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.xhh.enjoyapp.Bean.Post;
import com.xhh.enjoyapp.R;

import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.QueryListener;

/**
 * @description 登录后查询内容
 * @author: weiXhh
 * @create: 2020-05-14 14:06
 **/
public class Receive extends AppCompatActivity {

    private TextView username;
    private TextView content;
    private TextView time;
    private ImageView ivBlack;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_receive);

        initView();
        initData();

        ivBlack.setOnClickListener(click->{
            finish();
        });
    }

    private void initData() {
        Intent intent = getIntent();

        String intentUsername = intent.getStringExtra("username");
        String intentContent = intent.getStringExtra("content");
        String intentTime = intent.getStringExtra("time");
        username.setText(intentUsername);
        content.setText(intentContent);
        time.setText(intentTime);

//        String id = intent.getStringExtra("id");
//
//        BmobQuery<Post> query = new BmobQuery<>();
//        query.getObject(id, new QueryListener<Post>() {
//            @Override
//            public void done(Post post, BmobException e) {
//                if(e == null){
//                   username.setText(post.getName());
//                   content.setText(post.getContent());
//                   time.setText(post.getCreatedAt());
//                } else {
//                    Log.e("ReceiveActivity", "获取失败" + e);
//                    Toast.makeText(Receive.this, "获取失败", Toast.LENGTH_SHORT).show();
//                }
//            }
//        });
    }

    private void initView() {
        username = findViewById(R.id.tv_receive_username);
        content = findViewById(R.id.tv_receive_content);
        time = findViewById(R.id.tv_receive_time);
        ivBlack = findViewById(R.id.receive_back);
    }
}
